﻿<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width,height=device-height, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0,shrink-to-fit=no" />
<meta name="format-detection" content="telephone=no" />
<!--em标准js代码，请放在页面的最上方，前面最好不要再有JS代码或JS文件-->
<script type="text/javascript" src="/js/rem.js"></script>
<link type="text/css" rel="stylesheet" href="/css/css.css" />
<link type="text/css" rel="stylesheet" href="/css/style.css" />
<title>东易日盛装饰开业盛典</title>
</head>

<body>		
	
	<div class="header">
		<a href="javascript:history.go(-1);" class="backa"></a>

		<a href="javascript:;" class="seta"></a>
	</div>	

	<div class="main main2">
		<div class="wp1">
			<div class="wp2">
				
				<div class="t1">活动报名</div>

				<input type="text" class="p3_inp" id="name" name="name" placeholder="姓名">
				<input type="text" class="p3_inp" id="mobile" name="mobile" placeholder="手机">
				<input type="text" class="p3_inp" id="community" name="community" placeholder="小区">
				<!--<input type="text" class="p3_inp" id="address" name="address" placeholder="门牌号">-->
				<input type="text" class="p3_inp" id="houseType" name="houseType" placeholder="面积(平方米)">
				<input type="hidden" class="p3_inp" id="desId" name="desId" placeholder="推荐人"><br>
				<span id="msg" class="p3_inp" style="color: red;text-align: center;border: none"></span>


				<a href="javascript:;" class="go" id="bmBtn" onclick="apply();">确认</a>

			</div>
		</div>
	</div>

	<img src="/images/bodysd.jpg" alt="" class="sd">
</body>
<script type="text/javascript" src="/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="/js/base.js"></script>
<script type="text/javascript" src="/js/popups.js"></script>
<script type="text/javascript">

	$(function () {
		getDesId();
	});

	function getDesId() {
		$.ajax({
			url: "/customer/getDesId",
			method: "get",
			data: "",
			success: function (data) {
				$("#desId").val(data)
			}
		})
	}

	function apply() {
		var flag=true;
		var name=$("#name").val();
		var mobile=$("#mobile").val();
		var community=$("#community").val();
		var address=$("#address").val();
		var houseType=$("#houseType").val();
		var desId=$("#desId").val();

		//非空验证
		if (!checkhouseType(houseType)){flag=false;}
		if (!checkaddress(address)){flag=false;}
		if (!checkcommunity(community)){flag=false;}
		if (!checkmobile(mobile)){flag=false;}
		if (!checkname(name)){flag=false;}

		if(flag){
			$.ajax({
				url:"/customer/apply",
				method:"post",
				data:{
					name:name,
					mobile:mobile,
					community:community,
					address:address,
					houseType:houseType,
					desId:desId,
				},
				success:function (data) {
					if(data==1){
						$("#msg").text("该电话号码已报名")
					}
					if(data==2){
						$("#msg").text("该微信号已报名")
					}
					if(data==0){
						jqtoast("报名成功");
						setTimeout(function () {
							location.href="/customer/applyed"
						},2000)
					}
				}
			})
		} else {
			return ;
		}
	}

	//非空验证
	function checkname(name) {
		if(name==""){
			$("#msg").text("姓名不为空");
			return false;
		} else {
			return true;
		}
	}

	function checkmobile(mobile) {
		var mobileReg=/^1\d{10}$/;
		if(mobile==""){
			$("#msg").text("联系电话不为空");
			return false;
		}else if(!(mobileReg.test(mobile))){
			$("#msg").text("手机号码有误");
			return false;
		} else {
			return true;
		}
	}

	function checkcommunity(community) {
		if(community==""){
			$("#msg").text("小区不为空");
			return false;
		} else {
			return true;
		}
	}

	function checkaddress(address) {
		if(address==""){
			$("#msg").text("门牌号不为空");
			return false;
		} else {
			return true;
		}
	}

	function checkhouseType(houseType) {
		if(houseType==""){
			$("#msg").text("户型不为空");
			return false;
		} else {
			return true;
		}
	}


</script>
</html>